
//
//  MVHotCollectionReusableView.m
//  NewMusic
//
//  Created by dllo on 15/11/21.
//  Copyright © 2015年 Going. All rights reserved.
//

#import "MVHotCollectionReusableView.h"
#import "UIView+WJLSetBaseView.h"
#import "MVTypeModel.h"
@interface MVHotCollectionReusableView ()
@property(nonatomic, retain) UILabel *lineLabel;
@end


@implementation MVHotCollectionReusableView
- (void)dealloc {
    [_allButton release];
    [_HotButton release];
    [_NewButton release];
    [_lineLabel release];
    [super dealloc];
}
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        //创建视图
        [self createSubView];
    }
    return self;
}
#pragma mark 创建视图
- (void)createSubView {
    //全部
    self.allButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [_allButton setTitle:@"全部" forState:UIControlStateNormal];
    _allButton.layer.borderWidth = 1;
    _allButton.titleLabel.font = [UIFont systemFontOfSize:15];
    _allButton.layer.borderColor = [UIColor colorWithRed:56 / 255.0 green:192 / 255.0 blue:107 / 255.0 alpha:1.0].CGColor;
//    _allButton.backgroundColor = [UIColor cyanColor];
    [self addSubview:_allButton];
    
    //最热
    self.HotButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [_HotButton setTitle:@"最热" forState:UIControlStateNormal];
    _HotButton.titleLabel.font = [UIFont systemFontOfSize:15];
    [_HotButton setTitleColor:[UIColor colorWithRed:56 / 255.0 green:192 / 255.0 blue:107 / 255.0 alpha:1.0] forState:UIControlStateNormal];
//    _HotButton.backgroundColor = [UIColor blueColor];
    [self addSubview:_HotButton];
    
    //最新
    self.NewButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [_NewButton setTitle:@"最新" forState:UIControlStateNormal];
//    _NewButton.backgroundColor = [UIColor purpleColor];
    _NewButton.titleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:_NewButton];
    
    //竖线
    self.lineLabel = [[UILabel alloc]init];
    _lineLabel.backgroundColor =[UIColor whiteColor];
    [self addSubview:_lineLabel];
    [_lineLabel release];
}
#pragma mark 设置大小
- (void)layoutSubviews {
    [super layoutSubviews];
    _allButton.frame = CGRectMake(10, 10, 70, self.height - 20);
    _HotButton.frame = CGRectMake(self.width / 2 + 70, _allButton.y, 40, _allButton.height);
    _lineLabel.frame = CGRectMake(_HotButton.rightX + 2, _HotButton.y, 1, _HotButton.height);
    _NewButton.frame = CGRectMake(_lineLabel.rightX + 2, _lineLabel.y, _HotButton.width, _HotButton.height);
}
#pragma mark 重写titileString的setter方法
- (void)setTitleString:(NSString *)titleString {
    if (_titleString != titleString) {
        [_titleString release];
        _titleString = [titleString copy];
    }
    if ([titleString isEqualToString:@""]) {
        [_allButton setTitle:@"全部" forState:UIControlStateNormal];
    }else {
        [_allButton setTitle:titleString forState:UIControlStateNormal];
    }
}
@end
